import java.util.Arrays;
import java.util.Scanner;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2022/6/26
 * \* Time: 16:41
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public class TestDemo {

    public static <flg1> void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] arrStr = new String[n];
        for(int i = 0 ; i < n;i++){
            arrStr[i] = sc.next();
        }
        boolean flg1 = isLen(arrStr);
        boolean flg2 = isZi(arrStr);
        if(flg1 && flg2){
            System.out.println("both");
        }else if(flg1){
                System.out.println("lengths");
        }else if(flg2){
                System.out.println("lexicographically");
        }else{
            System.out.println("none");
        }
    }
    public static boolean isLen(String[] arrStr){
        for(int i =0 ; i < arrStr.length - 1 ;i++){
            if(arrStr[i].length() > arrStr[i+1].length()){
                return false;
            }
        }
        return true;
    }
    public static boolean isZi(String[] arrStr){
        for(int i = 0 ; i < arrStr.length - 1;i++){
            if(arrStr[i].compareTo(arrStr[i+1]) > 0){
                return false;
            }
        }
        return true;
    }


    public static void main2(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int n = sc.nextInt();
            int [] arr = new int[3*n];
            for(int i = 0 ; i < (3*n) ; i++){
                arr[i] = sc.nextInt();
            }
            Arrays.sort(arr);
            int sum = 0;
            for(int i = 0; i < n ;i++){
                sum += arr[arr.length-(2*(i+1))];
            }
            System.out.println(sum);
        }
    }

    public static void main1(String[] args) {
        byte[][] direct = {{-1, 0},{1, 0},{0,-1},{0,1}};
        int x = 0;
        int y = 0;
        for(int i = 0 ; i < 4;i++){
            int nx = x + direct[i][0];
            int ny = y + direct[i][1];
            System.out.println(nx);
            System.out.println(ny);
            System.out.println("-----");
        }
    }
}
